#@adminLayout()
#define main()
<div class="card">
    <div class="card-header">
        <h2 class="card-title">账户管理 / 分配角色</h2>
        <br/>
        <small>
            <lable>
                <a data-pjax href="/admin/sys/account" class="btn btn-secondary"><i
                        class="zmdi zmdi-arrow-back"></i>返回
                </a>
            </lable>
        </small>
    </div>
    <div class="row">
        <div class="col-sm-4">
            <div class="card profile">
                <div class="profile__img" style="width: 200px;height: 200px;margin-left: 20px;">
                    #if(model.avatar=="")
                    <p style="margin-left: 30px;margin-top: 30px;font-size: 16px;color: red;">暂无头像,请上传</p>
                    #else
                    <img src="/upload/avatar#(model.avatar??)" alt="">
                    #end
                </div>
                <div class="profile__info">
                    <ul class="icon-list">
                        <li><i class="zmdi zmdi-account-circle zmdi-hc-fw"></i>#(model.fullName??)
                        </li>
                        <li><i class="zmdi zmdi-email"></i> #(model.email??)</li>
                        <li><i class="zmdi zmdi zmdi-phone"></i> #(model.mobile??)</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="card-block">
                <table class="table table-hover mb-0" data-name="account">
                    <h2>正在为&emsp;<span style="color: red;">#(model.fullName??)</span>&emsp;分配角色
                    </h2>
                    <tbody>
                    #for(x : roleList)
                    <tr>
                        <td>
                            <span class="toggle-switch">
                                <input data-account-id="#(model.id)"
                                       data-role-id="#(x.id)"
                                       #if(x.assigned) checked #end
                                       type="checkbox" class="toggle-switch__checkbox">
                                <i class="toggle-switch__helper"></i>
                            </span>
                        </td>

                        <td>#(x.name)</td>
                    </tr>
                    #end
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="card-block">
                <span style="color: red;">点亮左侧开关分配角色，同一账号可分配多个角色</span>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        initSwitchInput(prepareAction);
        $('.modal-backdrop').remove();
        $('body').css("overflow", "auto");
    });

    function prepareAction($this, state) {
        return {
            url: state ? "/admin/sys/account/addRole" : "/admin/sys/account/deleteRole",
            data: {
                accountId: $this.data("account-id"),
                roleId: $this.data("role-id")
            }
        }
    }
</script>
#end
